package csvIO;

import java.util.HashSet;

public class CsvModifier {

	public static CsvObject trimFields(CsvObject object, HashSet<Integer> fielsIndexes){
		CsvObject newObject = new CsvObject();
		
		int count = object.getRowsCount();
		int length = object.getRowLength();
		
		for(int i = 0; i < count; i++){
			CsvRow row = new CsvRow(fielsIndexes.size());
			int rowCounter = 0;
			for(int f = 0; f < length; f++){
				if(fielsIndexes.contains(Integer.valueOf(f))){
					row.set(rowCounter++, object.getRow(i).get(f));
				}
			}
		newObject.addRow(row);
		}
		return newObject;
	}
	
}
